//
//  LLOrderDetailViewController.m
//  UserUse
//
//  Created by Yiwi on 16/10/18.
//  Copyright © 2016年 CJPC. All rights reserved.
//

#import "LLOrderDetailViewController.h"
#import "LLOrderDetailView.h"


@interface LLOrderDetailViewController ()<LLOrderDetailViewDelegate>{
    LLOrderDetailView * _detailView;
}

@end

@implementation LLOrderDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"订单详情";
    [self setupSubView];
    [self reloadData];
}

-(void)setupSubView{
    _detailView = [LLOrderDetailView new];
    _detailView.frame = kScreenFrame;
    _detailView.delegate = self;
    [self.view addSubview:_detailView];
}
-(void)reloadData{
    [_detailView setupOrderMessageWithOrderList:self.orderList];
}

-(void)concal{
//取消订单
#warning 待写逻辑 ：接口待写 取消订单
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"取消订单"
                                                                   message:@"订单取消后资金会在1-7个工作日内返回至您的账户，是否继续取消订单？"
                                                            preferredStyle:UIAlertControllerStyleAlert];
    
    [alert addAction:[UIAlertAction actionWithTitle:@"取消"
                                              style:UIAlertActionStyleCancel
                                            handler:^(UIAlertAction *action) {
                                                //取消订单
                                                
                                                [AllProjectRequest cancelOrderWithOrderId:self.orderList.context.orderid success:^(id responseObject) {
                                                    
                                                    [MBProgressHUD showTheMessage:responseObject[@"resultMassage"] with:nil];
                                                    [self.navigationController popViewControllerAnimated:YES];
                                                    
                                                } failure:^(NSString *error) {
                                                    
                                                }];
                                            }]];
    
    [alert addAction:[UIAlertAction actionWithTitle:@"不取消"
                                              style:UIAlertActionStyleDestructive
                                            handler:^(UIAlertAction *action) {
                                                NSLog(@"不取消");
                                            }]];
    
    [self presentViewController:alert animated:YES completion:nil];
    
}
-(void)complete{
//完成订单
#warning 待写逻辑 ：接口待写 完成订单
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"完成订单"
                                                                   message:@"订单完成之后不能取消。"
                                                            preferredStyle:UIAlertControllerStyleAlert];
    
    [alert addAction:[UIAlertAction actionWithTitle:@"完成"
                                              style:UIAlertActionStyleCancel
                                            handler:^(UIAlertAction *action) {
                                                [AllProjectRequest finishTheOrderWith:self.orderList.context.orderid success:^(NSMutableArray *listDatas) {
                                            [self.navigationController popViewControllerAnimated:YES];        
                                                    
                                                } failure:^(NSString *error) {
                                                    
                                                }];
                                            }]];
    
    [alert addAction:[UIAlertAction actionWithTitle:@"不完成"
                                              style:UIAlertActionStyleDestructive
                                            handler:^(UIAlertAction *action) {
                                                NSLog(@"不取消");
                                            }]];
    
    [self presentViewController:alert animated:YES completion:nil];
}

@end
